import logging
from redis import StrictRedis


class Config(object):
    SECRET_KEY = 'EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA'
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/information7'
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # REDIS 配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # 配置session保存位置
    SESSION_TYPE = 'redis'
    # 开启session 签名
    SESSION_USE_SIGNER = True
    # 配置redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 设置需要过期及过期时间
    PERMANENT_SESSION_LIFETIME = 84600 * 2

    # 默认日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopementConfig(Config):
    """开发模式下的配置"""
    DEBUG = True


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.ERROR


class Testing(Config):
    DEBUG = True
    # 设置这个属性可以在代码错误的时候更精确的找到错误的地方
    Testing = True

# 定义配置字典字典
config = {
    "development": DevelopementConfig,
    "production": ProductionConfig,
    "Testing": Testing
}